# -*- coding: utf-8 -*-
# @Author   : zxc19
# @Time     : 2023/7/6 20:20
# @FileName : image_utils.py
# @Desc     : 请输入功能模块描述
import ddddocr


class ImagesUtils(object):
    @staticmethod
    def get_image_code_by_pic(img_path: str):
        """
        获取图片文本
        :param img_path:
        :return:
        """
        ocr = ddddocr.DdddOcr(show_ad=False)
        with open(img_path, 'rb') as f:
            img_bytes = f.read()
        res = ocr.classification(img_bytes)
        return res

    @staticmethod
    def get_image_code_by_stream(img_bytes: bytes):
        """
        获取数据流图片文本
        :param img_bytes:
        :return:
        """
        ocr = ddddocr.DdddOcr(show_ad=False)

        res = ocr.classification(img_bytes)
        return res
